﻿var hikApiPreView = {
	getActiveX : function(id) {
		var _this=this;
		var ocx =document.getElementById(id);
		return ocx;
	},
	setLocalParams : function(id) {//设置本地参数
		_this =this;
		var ocxObj = _this.getActiveX(id);
		var devPxRa = screen.deviceXDPI / screen.logicalXDPI;
		var height = ocxObj.height * devPxRa;
		var width = ocxObj.width * devPxRa;
		var xml = '<?xml version="1.0" encoding="UTF-8"?> ' 
				+ '<localParam> '
				+ '<width>' + width + '</width> '
				+ '<height>' + height + '</height> '
				+ '<picType>0</picType> '
				+ '<capturePath>C:\\Hikvision</capturePath> '
				+ '<recordSize>2</recordSize> '
				+ '<recordPath>C:\\Hikvision</recordPath> '
				+ '<limitPreviewTime>0</limitPreviewTime> '
				+ '<showMsgTip>0</showMsgTip></localParam>';
		var ret = ocxObj.MPV_SetLocalParam(xml);
		return ret;
	},
	init : function(id,wnds) {//初始化
		var _this=this;
		var ocxObj = _this.getActiveX(id);
		var languageType = 1;
		var ret =ocxObj.MPV_Init(languageType);
		_this.setLocalParams(id);
		_this.setMainMenuBarHide(id);
		_this.setMenuBar(id);
		_this.setPlayWindowCount(id,wnds);
	},
	setPlayWindowCount:function(id,wnds){
		_this =this;
		var ret = _this.getActiveX(id).MPV_SetPlayWndCount(parseInt(wnds, 10));
		if(ret!=0){
			alert("设置分屏失败!");
		}
	},
	getPlayWindowCount:function(id){
		_this =this;
		return _this.getActiveX(id).MPV_GetPlayWndCount();
	},
	setMenuBar:function(id){//隐藏插件工具栏
		_this =this; 
		//var ids="0,1,2,3,4,5,6,7,9,10,11,12,13,14";//关闭预览按钮
		var ids="";//关闭预览按钮
		var ret =  _this.getActiveX(id).MPV_SetToolBar(ids);
		if (ret != 0) {
			alert("自定义播放工具条按钮失败！");
		}
	},
	setMainMenuBar:function(id){
		_this =this;
		var ids="0,1,2,3,4,5,6"; 
		var ret =  _this.getActiveX(id).MPV_SetMainToolBar(ids);
		if (ret != 0) {
			alert("设置主工具栏失败");
		}
	},
	setMainMenuBarHide:function(id){
		_this =this;
		var ret =  _this.getActiveX(id).MPV_ShowMainToolBar(0);
		if (ret != 0) {
			alert("隐藏主工具栏失败");
		}
	}
}
